package com.graduation.smartparkingplatform.Utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateToWeek {
  public static String toWeek(String datetime) throws ParseException {
    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
    String[] weekDays = {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"};
    Calendar cal = Calendar.getInstance();
    Date date;
    date = sf.parse(datetime);
    cal.setTime(date);
    // 一周的第几天
    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
    if (w < 0) w = 0;
    return weekDays[w];
  }
}
